<template> 
    <div class="container">
        <div class="userinfo" >
            <!-- <img :src="userinfo.avatarUrl" alt="">  -->
            <p>{{userinfo.nickName}}</p> 
        </div> 
        <YearProgress></YearProgress> 
        <button v-if='userinfo.openId' @click='scanBook' class='btn'>添加图书</button> 
        <button v-else open-type="getUserInfo" lang="zh_CN" class='btn' @getuserinfo="doLogin">点击登录</button> 
    </div> 
</template>
<script>

import qcloud from 'wafer2-client-sdk' 
// import YearProgress from '@/components/YearProgress' 
// import {showSuccess, post, showModal} from '@/util' 
import config from '@/config'
export default { 
    data () {
        return {
            userinfo:{}
        }
    },
    methods: {
        scanBook() {

        },
        doLogin: function (e) {
            qcloud.setLoginUrl(config.loginUrl)
            qcloud.login({
                success: function (userInfo) {
                console.log('登录成功', userInfo)
                },
                fail: function (err) {
                console.log('登录失败', err)
                }
            })
        }
    }
}

</script>

<style lang='scss'>
.container{
  padding:0 30rpx;

}  
.userinfo{
  margin-top:100rpx;
  text-align:center;
  img {
    width:150rpx;
    height:150rpx;
    margin:20rpx;
    border-radius:50%
  }
}
</style>

